<template>
	<view class="loginbox">
		<div class="login">
			<div>
				<div class="text">创建用户</div>
				<input v-model="username" name="uname" label="用户名" placeholder="请输入用户名" />
				<div class="text">密码</div>
				<input v-model="password" type="password" name="upass" label="密码" placeholder="请输入密码" />
				<div class="text">确认密码</div>
				<input v-model="newpassword" type="password" name="upass" label="密码" placeholder="请再次确认密码" />

				<div class="button">
					<button round block type="info" native-type="submit" @click="register">注册</button>
				</div>

				<div class="button" @click="login">
					<div round block type="info" native-type="submit" class="logins">——— 返回登录 ———</div>
				</div>


			</div>

		</div>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				username: '',
				password: '',
				newpassword:'',
			}
		},
		methods: {
			register() {
				if (this.username.trim() !== '' && this.password.trim() !== '' && this.password.trim() === this.newpassword.trim() ) {
					uni.navigateTo({
						url: "../login/login"
					})
				}
				else if(this.username.trim() === '' || this.password.trim() === '' || this.newpassword.trim() === ''){
					uni.showToast({
						title:'输入框不能为空',
						icon:'none'
					})
				}
				else{
					uni.showToast({
						title:'两次输入的密码不一致',
						icon:'none'
					})
				}
			},
			
			login() {
				uni.navigateTo({
					url: "../login/login"
				})
			}
		}
	}
</script>

<style lang="less" scoped>
	.loginbox {
		height: 100vh;
		margin-top: 150px;
	}

	.login {
		margin: 10px;

	}

	input {
		font-size: 15px;
		margin: 0px 0px 30px 20px;
		// background-color:red;
		// border: 1px solid gray;
		padding: 10px;
		border-radius: 25px;
	}

	.text {
		margin: 10px;
		font-family: "华文行楷";
	}

	.button {
		margin: 0px 60px;
	}

	.button button {
		font-size: 15px;
		border: 0px solid transparent;
		border-radius: 30px;
		margin-bottom: 30px;

		background-color: skyblue;
	}

	.logins {
		// margin-top:30px;
		// background-color: gray;
		margin-top: 60px;
		text-align: center;
		color: gray;
	}
</style>